fix: auto-adapt LeRobot state dimension instead of raising ValueError#82
Merged
cagataycali merged 3 commits intostrands-labs:mainfrom Apr 3, 2026
Merged
Conversation
When a robot exposes more joints than the policy was trained on (e.g. aloha has 16 joints but ACT expects 14), the policy raised a hard ValueError during inference, making sim-to-real transfer fragile. Fix: truncate excess joints or zero-pad if fewer, with debug logging. This is the standard approach in robotics — LeRobot's own teleoperation code does the same.
This was referenced Apr 1, 2026
Address review feedback: state dimension truncation/padding should be visible to operators since it can affect device behavior.
yinsong1986
reviewed
Apr 1, 2026
Address review: include robot_state_keys hint in truncation/padding warnings so users can diagnose joint count mismatches.
yinsong1986
approved these changes
Apr 1, 2026
yinsong1986
left a comment
There was a problem hiding this comment.
All review comments addressed. LGTM.
awsarron
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
When a robot exposes more joints than the policy was trained on (e.g. aloha has 16 joints but ACT expects 14), the policy raised a hard
ValueErrorduring inference. This fix auto-adapts state dimensions — truncate excess or zero-pad if fewer — with debug logging.What changed
strands_robots/policies/lerobot_local/policy.pyValueErrorwith truncate/zero-pad + debug loggingtests/test_lerobot_local.pyraisesWhy
This is the standard approach in robotics — LeRobot's own teleoperation code does the same. Hard crashing on dimension mismatch makes sim↔real transfer fragile and prevents running policies trained on one embodiment on another with different joint counts.
Testing
test_state_padded_to_expected_dimto verify auto-pad behaviorruff check+ruff format --check)Part 1 of 6 in the MuJoCo simulation PR decomposition (see PR_TASKS.md)